﻿using System;
using System.Threading;
using Newtonsoft.Json;
using RosSharp.RosBridgeClient;
using RosSharp.RosBridgeClient.MessageTypes.Geometry;
using RosSharp.RosBridgeClient.MessageTypes.Std;
using WebSocketSharp;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string uri = "ws://192.168.20.132:9090";
                RosSocket RosSocket = new RosSocket(new RosSharp.RosBridgeClient.Protocols.WebSocketSharpProtocol(uri));
                string id = RosSocket.Advertise<Twist>("/turtle1/cmd_vel");
                while (true)
                {
                    Twist message = new Twist();
                    message.linear.x = 1;
                    message.linear.y = 0;
                    message.linear.z = 0;
                    message.angular.x = 0;
                    message.angular.y = 0;
                    message.angular.z = 1;
                    RosSocket.Publish(id, message);
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
}
